#include <stdio.h>
#include <md5.h>
#include "tools.h"

char* file_md5(const char* path,unsigned char* decrypt)
{
	FILE *fp = fopen(path,"rb");
	if(fp == NULL) 
	{
		perror("fopen");
		return NULL;
	}
	
	MD5_CTX md5;	
	MD5Init(&md5);
	unsigned char encrypt[1024];
	while(!feof(fp)) 
	{
		MD5Update(&md5, encrypt, fread(encrypt, 1, sizeof(encrypt), fp));
	}
	fclose(fp);
			
	MD5Final(&md5, decrypt);

	return decrypt;
}
